home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0125_Scrolling Images.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  96 lines

  1. {
  2. Michael, you wondered how you could scroll an image (320*200) over the
  3. screen. And yes, as you probably have figured out, the most reliable
  4. solution to that is mode-x (or tweaked mode or whatever...).
  5. Here's an example program:
  6.  
  7. --------------------------------------------------------->8-------------------
  8. {
  9.  
  10.  Mode-x scrolling, by Jens Larsson 2:201/2120.3, Sweden, PD.
  11.  ( btw, hope you know some assembly... <g> )
  12.  
  13. }
  14. {$G+}
  15. Uses Crt;
  16.  
  17.    Var i, ScrBase : Word;
  18.  
  19.     Procedure PutPix(x, y : Word; Color : Byte); Assembler;
  20.       Asm
  21.         mov     ax,0a000h
  22.         mov     es,ax
  23.         mov     bx,x
  24.         mov     dx,3c4h
  25.         mov     ax,0102h
  26.         mov     cl,bl
  27.         and     cl,3
  28.         shl     ah,cl
  29.         out     dx,ax
  30.         mov     ax,y
  31.         shl     ax,4
  32.         mov     di,ax
  33.         shl     ax,2
  34.         add     di,ax
  35.         shr     bx,2
  36.         add     di,bx
  37.         add     di,ScrBase
  38.         mov     al,Color
  39.         mov     es:[di],al
  40.       End;
  41.  
  42.     Procedure ScrPan(ScrOfs : Word); Assembler;
  43.       Asm
  44.         mov     bx,ScrOfs
  45.         mov     dx,3d4h
  46.         mov     ah,bh
  47.         mov     al,0ch
  48.         out     dx,ax
  49.         mov     ah,bl
  50.         inc     al
  51.         out     dx,ax
  52.       End;
  53.  
  54.     Procedure SetModeX; Assembler;
  55.       Asm
  56.         mov     ax,0012h
  57.         int     10h
  58.         mov     ax,0013h
  59.         int     10h
  60.         mov     dx,3c4h
  61.         mov     ax,0604h
  62.         out     dx,ax
  63.         mov     dx,3d4h
  64.         mov     ax,0014h
  65.         out     dx,ax
  66.         mov     ax,0e317h
  67.         out     dx,ax
  68.       End;
  69.  
  70.     Procedure Synk; Assembler;
  71.       Asm
  72.         mov     dx,3dah
  73. @L1:
  74.         in      al,dx
  75.         test    al,08h
  76.         jne     @L1
  77. @L2:
  78.         in      al,dx
  79.         test    al,08h
  80.         je      @L2
  81.       End;
  82.  
  83.        Begin
  84.          Randomize;
  85.          SetModeX;
  86.          ScrBase := 200*80;
  87.          For i := 0 to 9999 do PutPix(Random(320),Random(200),Random(256));
  88.          For i := 0 to 200 do Begin
  89.            ScrPan(i*80);
  90.            Synk;
  91.           End;
  92.          ReadKey;
  93.          Asm; mov ax,0003h; int 10h; End;
  94.        End.
  95.  
  96.